<template>
  <div class="content-block block-half-2">
    <div class="info-head">{{ title }}</div>
    <div class="info-content">
      <v-chart :option="chartOption" style="width: 100%;height: 400px;"></v-chart>
    </div>
  </div>
</template>

<script>
export default {
  name: 'grid-item-three',
  props: {
    title: String,
  },
  computed: {
    energyVariety () {
      return this.$store.state.energyVariety
    },
    chartOption () {
      return {
        legend: {
          left: 'center'
        },
        tooltip: {
          trigger: 'item'
        },
        series: [
          {
            name: this.title,
            type: 'pie',
            radius: [50, 130],
            center: ['50%', '50%'],
            roseType: 'area',
            itemStyle: {
              borderRadius: 8
            },
            data: this.energyVariety.map(v => ({
              name: v.name,
              value: (Math.random() * 100).toFixed(2)
            }))
          }
        ]
      }
    }
  },
  mounted () {
    this.$store.dispatch('GET_ENERGY_VARIETY')
  },
}
</script>
